package com.training.admin.entity.project;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;
import org.springframework.format.annotation.DateTimeFormat;

import com.training.admin.entity.course.Course;
import com.training.admin.entity.trainer.Trainer;


/**
 * 项目-期-课程
 * @author Rockett
 *
 */
@Entity
@Table(name = "project_phase_course")
public class ProjectPhaseCourse {
    
	/**
	 * ID
	 */
    @Id
    @GeneratedValue
    private Long id;
    
    /**
     * 项目-期
     */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private ProjectPhase projectPhase;
    
    /**
     * 课程
     */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Course course;
    
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    private Trainer trainer;
  
    /**
     * 开始日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Type(type = "date")
    private Date beginDate;
   
    /**讲师评分*/
    private String trainerSurveyResult;
   
    /**课程评分*/
    private String courseSurveyResult;
   
    /**建议*/
    private String surveySuggestion;

    /**
     * 是否可用
     */
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * 
     * @return
     */
    public ProjectPhaseCourse delete() {
    	this.disabled = true;
    	return this;
    	
    }
    

    public boolean isDisabled() {
		return disabled;
	}


	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}


	public Trainer getTrainer() {
		return trainer;
	}


	public void setTrainer(Trainer trainer) {
		this.trainer = trainer;
	}


	/**
	 * @return the trainerSurveyResult
	 */
	public String getTrainerSurveyResult() {
		return trainerSurveyResult;
	}


	/**
	 * @param trainerSurveyResult the trainerSurveyResult to set
	 */
	public void setTrainerSurveyResult(String trainerSurveyResult) {
		this.trainerSurveyResult = trainerSurveyResult;
	}


	/**
	 * @return the courseSurveyResult
	 */
	public String getCourseSurveyResult() {
		return courseSurveyResult;
	}


	/**
	 * @param courseSurveyResult the courseSurveyResult to set
	 */
	public void setCourseSurveyResult(String courseSurveyResult) {
		this.courseSurveyResult = courseSurveyResult;
	}


	/**
	 * @return the surveySuggestion
	 */
	public String getSurveySuggestion() {
		return surveySuggestion;
	}


	/**
	 * @param surveySuggestion the surveySuggestion to set
	 */
	public void setSurveySuggestion(String surveySuggestion) {
		this.surveySuggestion = surveySuggestion;
	}


	/** 
     * 结束日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Type(type = "date")
   private Date endDate;
    
    
    /**
     * The default constructor
     */
    public ProjectPhaseCourse() {
    	this.disabled=false;
    }
    
    public ProjectPhaseCourse(ProjectPhaseCourse oldProjectPhaseCourse) {
        this.course = oldProjectPhaseCourse.getCourse();
        this.trainer = oldProjectPhaseCourse.getTrainer();
        this.beginDate = oldProjectPhaseCourse.getBeginDate();
        this.trainerSurveyResult = null;
        this.courseSurveyResult = null;
        this.disabled = false;
    }
    
    /**
     * @param trainer
     * @param projectPhase
     * @param course
     */
    public ProjectPhaseCourse(Trainer trainer, ProjectPhase projectPhase, Course course) {
        this.course = course;
        this.projectPhase = projectPhase;
        this.trainer = trainer;
        this.disabled = false;
    }
    
    /**
     * @param trainer
     * @return
     */
    public ProjectPhaseCourse editTrainer(Trainer trainer) {
        this.trainer = trainer;
        return this;
    }
    
    public ProjectPhaseCourse editProjectPhaseCourse(Trainer trainer, Course course) {
        this.course = course;
        this.trainer = trainer;
        return this;
    }
    
    /**
     * 
     * @param projectPhase
     * @return
     */
    public ProjectPhaseCourse init(ProjectPhase projectPhase) {
        this.projectPhase = projectPhase;
        return this;
    }
    
    /**
     * @return
     */
    public ProjectPhaseCourse editDisabled() {
        this.disabled = true;
        return this;
    }
    

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }


    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }


	/**
	 * @return the projectPhase
	 */
	public ProjectPhase getProjectPhase() {
		return projectPhase;
	}


	/**
	 * @param projectPhase the projectPhase to set
	 */
	public void setProjectPhase(ProjectPhase projectPhase) {
		this.projectPhase = projectPhase;
	}


	/**
	 * @return the course
	 */
	public Course getCourse() {
		return course;
	}


	/**
	 * @param course the course to set
	 */
	public void setCourse(Course course) {
		this.course = course;
	}


	/**
	 * @return the beginDate
	 */
	public Date getBeginDate() {
		return beginDate;
	}


	/**
	 * @param beginDate the beginDate to set
	 */
	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}


	/**
	 * @return the endDate
	 */
	public Date getEndDate() {
		return endDate;
	}


	/**
	 * @param endDate the endDate to set
	 */
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}



}